﻿using System.Diagnostics.CodeAnalysis;

namespace Modules.Payroll.Comparers;

internal class WagePayrollDetailComparer : IEqualityComparer<WagePayrollDetail>
{
    public bool Equals(WagePayrollDetail? x, WagePayrollDetail? y)
    {
        if (x == null && y == null)
            return true;
        else if (x == null || y == null)
            return false;
        else if (x.PayrollId == y.PayrollId && x.Month == y.Month && x.MemberId == y.MemberId)
            return true;
        else
            return false;
    }

    public int GetHashCode([DisallowNull] WagePayrollDetail obj)
    {
        return $"{obj.PayrollId}{obj.Month}{obj.MemberId}".GetHashCode();
    }
}
